<template>


  <div>
    <div style="margin-left: 66%">

      <font>欢迎：</font>
      <router-link to="FuserSelf" >
        &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;{{$store.state.user.list.username}}&nbsp;&nbsp;&nbsp;&nbsp;
      </router-link>
      <!--    {{$store.state.loginUser.uid}}-->
     &nbsp;&nbsp;
      <router-link to="/" tag="a"> <span>退出</span></router-link>
    </div>
    <el-menu
      :default-active="activeIndex2"
      class="el-menu-demo"
      mode="horizontal"
      @select="handleSelect"
      background-color="#545c64"
      text-color="#fff"
      active-text-color="#ffd04b">
      <el-menu-item index="1">
        <router-link to="/bm">图书查看</router-link>
      </el-menu-item>

      <el-submenu index="2">
        <template slot="title">个人信息</template>
        <el-menu-item index="2-1" @click="dialogVisible = true">个人信息修改</el-menu-item>
        <el-menu-item index="2-2">在线客服</el-menu-item>
      </el-submenu>
<!--      <el-menu-item index="4"><router-link to="/forder">订单管理111</router-link></el-menu-item>-->
      <el-menu-item index="5"><router-link to="/cart">购物车</router-link></el-menu-item>
      <el-menu-item index="4"><router-link to="/site">地址</router-link></el-menu-item>
      <el-menu-item index="6"><router-link to="/forde">订单管理</router-link></el-menu-item>
      <el-menu-item index="7"><router-link to="/activity">限时抢购</router-link></el-menu-item>
    </el-menu>

    <el-dialog
      :data="list"
      title="提示"
      :visible.sync="dialogVisible"
      width="30%"
      :before-close="handleClose">
      <span slot="footer" class="dialog-footer">
        <div style="text-align: center;margin-top: -30px">
        <span float="left">用户名&nbsp;:&nbsp;</span><el-input  v-model="lists.username" style="width: 280px"></el-input><br><br>
<!--        <span float="left" >密&nbsp;&nbsp; 码&nbsp;:&nbsp; </span><el-input v-model="lists.password" disabled property="password"  placeholder="请输入密码" style="width: 280px"></el-input><br><br>-->
        <span float="left">手机号&nbsp;: &nbsp;</span><el-input v-model="lists.phone" property="phone"  placeholder="请输入手机号" style="width: 280px"></el-input><br><br>
        <span float="left">身份证号&nbsp;:&nbsp; </span><el-input v-model="lists.idnumber" property="idnumber" placeholder="请输入身份证号" style="width: 280px"></el-input><br><br>
      </div>
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="update()">确 定</el-button>
  </span>
    </el-dialog>
  <div>
    <router-view></router-view>
  </div>
  </div>
</template>



<script>
export default {
  data() {
    return {
      activeIndex: '1',
      activeIndex2: '1',
      input: '',
      names:[],
      drawer:false,
      innerDrawer: false,
      lists:{
        username:"",
        pas:"",
        phone:"",
        idnumber:""
      },
      list:{
        username:'',
        password:'',
        idnumber:'',
        phone:''
      },
      dialogVisible: false,
    };
  },
  created () {
    // let a = sessionStorage.getItem('a')
    // console.log(a)
    // console.log(localStorage.getItem('b'))
    // alert(this.$store.state.loginUser.name)
    let n=this.$store.state.user.list.username;
    //this.lists=this.$store.state.loginUser
    this.lists=this.$store.state.user.list;
    this.$http.post('/fuser/login',n).then(response => {
      this.list = response;
       // alert(list.idnumber);
      console.log(this.list.idnumber+"============================");
    }).catch(error => {
      console.log(error)
    })
  },
  methods: {
    handleSelect(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(done) {
      this.$confirm('确认关闭？')
        .then(_ => {
          done();
        })
        .catch(_ => {});
    },
    update(){
      this.$http.post("/fuser/update",this.lists).then(update=>{
        if (update>0){
          alert("修改成功")
          this.dialogVisible=false
        }else{
          alert("修改失败")
        }
      })
    }
  }
}
</script>
